package com.tricky.demo.rabbit.config;

import org.springframework.amqp.core.*;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
public class RabbitMQConfiguration {

	@Bean
	public DirectExchange demoExchange() {
		return new DirectExchange (EnumRabbitQueue.Demo.getExchange(), true, false);
	}

	@Bean
	public Queue demoQueue() {
		return new Queue(EnumRabbitQueue.Demo.getName(), true); //队列持久
	}

	@Bean
	public Binding demoBinding() {
		return BindingBuilder.bind(demoQueue()).to(demoExchange()).with(EnumRabbitQueue.Demo.getRouteKey());
	}


	@Bean
	public TopicExchange zmmExchange() {
		return new TopicExchange(EnumRabbitQueue.Zmm.getExchange(), true, false);
	}

	@Bean
	public Queue zmmQueue() {
		return new Queue(EnumRabbitQueue.Zmm.getName(), true); //队列持久
	}

	@Bean
	public Binding zmmBinding() {
		return BindingBuilder.bind(zmmQueue()).to(zmmExchange()).with(EnumRabbitQueue.Zmm.getRouteKey());
	}


}
